﻿<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <title>Document</title>
    <script>
        function Edit_Article(ID) {
            $.post(
                "@Url.Action("Edit_Article", "Interaction")",
                { "id": ID }
            );
        }
    </script>
</head>
<body>
    <div class="frame_main">
        <ul>
            <li class="frame_title_line">
                <div class="frame_title">我的文章</div>
            </li>

            <li class="detaile_line">
                <table>
                    <tbody>
                        <tr class="td_head" height="45">
                            <td style="width:5%;">选择</td>
                            <td style="width:15%;">文章标题</td>
                            <td style="width:5%;">撰写人</td>
                            <td style="width:25%;">写作日期</td>
                            <td style="width:10%;">点击数</td>
                            <td style="width:20%;">分享给那些人看</td>
                            <td style="width:20%;">操作</td>
                        </tr>
                        @if (Model != null)
                        {
                            foreach (var item in Model)
                            {
                                var sharesName = "";
                                foreach (var str in item.Share_Article)
                                {
                                    sharesName += str.Students.Name + ",";
                                }
                                if (sharesName != "")
                                {
                                    sharesName = sharesName.Substring(0, sharesName.Length - 1);
                                }
                                <tr>
                                    <td><input type="checkbox" value="@item.ID" /></td>
                                    <td>@item.Title</td>
                                    <td>@item.Students.Name</td>
                                    <td>@item.Time</td>
                                    <td>@item.ClickRate</td>
                                    <td>@sharesName</td>
                                    <td>
                                        <p>
                                            <a href="javascript:;" onclick="window.open('@Url.Action("Details_Article", "Interaction", new { id = item.ID })', '', 'height=500,width=820,status=1,toolbar=no,menubar=no,location=no,scrollbars=yes,left=200,top=100,resizable=yes');">详情</a>
                                            <a href="@Url.Action("Edit_Article", "Interaction", new { id = @item.ID })">修改</a>
                                            <a href="javascript:;" onclick="window.open('@Url.Action("Details_HomeWork", "Study",new {id= item.ID})', '', 'height=500,width=820,status=1,toolbar=no,menubar=no,location=no,scrollbars=yes,left=200,top=100,resizable=yes');">分享</a>
                                            <a href="javascript:;" onclick="Delete_This(this,@item.ID)">删除</a>
                                        </p>
                                        <p>
                                            <a href="javascript:;" onclick="GetArticle_Comments(@item.ID)">管理评论</a>
                                        </p>
                                    </td>
                                </tr>
                            }
                        }
                        <tr>
                            <td colspan="8" style="text-align:left;">
                                <input type="checkbox" onclick="Check_all(this);" value=""><label>全选</label>&nbsp;
                                <a href="javascript:;" onclick="Delete_Checked()">
                                    <img src="~/Images/delete.gif" style="vertical-align:middle">删除
                                </a>&nbsp;
                            </td>
                        </tr>
                    </tbody>
                </table>
            </li>
        </ul>
    </div>
</body>
</html>
<script type="text/javascript" src="~/Content/EasyUi/jquery.easyui.min.js"></script>
<script>
    function Check_all(org) {
        if ($(org).attr("checked") == "checked")
            $("table :checkbox").attr("checked", true);
        else
            $("table :checkbox").attr("checked", false);
    }
    function Delete_This(org,id) {
        $.messager.confirm('警告', '你确定要删除吗?', function (r) {
            if (r) {
                $.post(
                    "@Url.Action("DelArticle", "Interaction")",
                    { "ids": id },
                    function () {
                        $(org).parent().parent().parent().remove();
                    });
            }
        });
    }
    function Delete_Checked() {
        var ids = "";
        $("table :checkbox:checked").each(function (index) {
            ids += $(this).val() + ",";
        });
        $.messager.confirm('警告', '你确定要删除选中的吗?', function (r) {
            if (r) {
                $.post(
                    "@Url.Action("DelArticle", "Interaction")",
                    { "ids": ids },
                    function () {
                        $("table :checkbox:checked").remove();
                    });
            }
        });
    }
</script>